package com.game.commons.scripts.java;

import java.io.File;

import com.game.commons.scripts.java.impl.ScriptContextImpl;


/**
 * 脚本加载卸载工厂类
 * @author 杜祥
 * @date 2013-6-26
 */
public class ScriptContextFactory 
{
	/**
	 * 创建脚本加载卸载类。并设置根目录和父脚本加载卸载类。
	 * @param root
	 * @param parent
	 * @return
	 * @throws InstantiationException
	 * 					java编译器不可用抛出此异常
	 */
	public static ScriptContext getScriptContext(File root, ScriptContext parent) throws InstantiationException
	{
		ScriptContextImpl ctx;
		if(parent == null)
		{
			ctx = new ScriptContextImpl(root);
		}
		else
		{
			ctx = new ScriptContextImpl(root, parent);
			parent.addChildScriptContext(ctx);
		}
		return ctx;
	}
}
